from langgraph.func import entrypoint
from langgraph.checkpoint.memory import MemorySaver
from langgraph.store.memory import InMemoryStore,BaseStore
from langgraph.types import StreamWriter
from langchain_core.runnables import RunnableConfig
from typing import Any

stoer = InMemoryStore()
checkpoint = MemorySaver()

@entrypoint(checkpointer=checkpoint,store=stoer)
def my_workflow(
        user_input:dict,
        *,
        previous:Any = None,
        store:BaseStore = None,
        writer:StreamWriter = None,
        config:RunnableConfig = None
):
    """一个复杂的演示入口点参数的工作流"""
    api_key_from_config = config['configurable'].get('api_version')
    writer(f"工作流 {config['metadata']['thread_id']} 以API版本启动{api_key_from_config}")
    return f"工作流处理的输入：{user_input}"

config = {"configurable":{"thread_id":"jack001","api_version":"11"}}
result = my_workflow.invoke({"message":"hello","api_version":"我的版本"},config)
print(result)